<?
if ($_GET[category]) {$save = $_GET[category];}

if ($srt == up) {
function fieldAsc ($x,$y) {
if($x[field] == $y[field]) return 0;
if($x[field] < $y[field]) return 1; return -1;
}
}

if ($srt == down) {
function fieldAsc ($x,$y) {
if($x[field] == $y[field]) return 0;
if($x[field] < $y[field]) return -1; return 1;
}
}

$file = file("base.dat");
$fp=fopen("tmp.dat","w");
flock($fp, LOCK_EX);
for($i=0; $i<count($file); $i++){
fwrite($fp, $file[$i]);
}
flock($fp, LOCK_UN);
fclose($fp);
$file = file("tmp.dat");
$fp = fopen("tmp.dat", "w");
flock($fp, LOCK_EX);
for($i=0;$i<count($file);$i++) {
list($id,$nick,$url,$mail,$category,$htmltext,$htmlimage,$urlink,$check_result,$check_next,$ip,$check_date) = explode("|", $file[$i]);
$tmp[$i] = array (field => $id, ext => "$nick|$url|$mail|$category|$htmltext|$htmlimage|$urlink|$check_result|$check_next|$ip|$check_date");
}
usort($tmp, fieldAsc);
foreach($tmp as $val) fputs ($fp, "$val[field]|$val[ext]");
flock($fp, LOCK_UN);
fclose($fp);

$id="";
$nick="";
$url="";
$mail="";
if ($save) {$_GET[category] = $save;} else {$_GET[category] = "";}
$htmltext="";
$htmlimage="";
$urlink="";
$check_result="";
$check_next="";
$ip="";
$check_date="";
?>